﻿using System.Windows;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        public static void MarkTextMidLine(Expressions.MarkText.AssistLine midLine)
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;

            LunarPresentation.Expressions.Expression curEx
                = Globals.selectedEditor.SelectedExpression;

            if (curEx is Expressions.MarkText == false)
            {
                MessageBox.Show("此操作只对“上下标式”有效！", Globals.appName,
                    MessageBoxButton.OK, MessageBoxImage.Warning);
                return;//子面板不支持Copy。
            }

            Expressions.MarkText mt = curEx as Expressions.MarkText;

            ModifingItem mi = new ModifingItem();
            Action actMidLine = new Action(curEx.ExID, -1, mt.GetType().Name,
                "MidLine", mt.Midline.ToString(), midLine.ToString());

            mt.Midline = midLine;

            mi.Add(actMidLine);

            mt.Editor.Do(mi);
            mt.Editor.IsModified = true;
        }
    }
}
